package dialogs.timeAlerts
{
	import Classes.CLoader;
	
	import UIFree.uif_component;
	import UIFree.uif_ecomponent;
	
	import flash.geom.Point;
	import flash.geom.Rectangle;

	public class pi_alertTUser extends pi_alertBaseTime {
	    private const genders: Object = ['f', 'm'];
//		protected const ref_id: String = '898787368';
		private var _banner: uif_ecomponent;
		public function pi_alertTUser(parent:uif_component, message:String, secCount:int, closeFunc:Function=null, completeFunc:Function=null) {
			super(parent, message, secCount, closeFunc, completeFunc);
			_button.width = 120;
			_button.x -= 40;
			_button.text = pi_data.SAVENOW;
//http://start.fotostrana.ru/vkontakte/dating/500x300/500x300_marks_blue_2011aseichas.swf			
		}
		
		override protected function createComponents(message: String, closeFunc: Function=null, cancelButton: Boolean = false): void {
			var url: String = 'http://start.fotostrana.ru/vkontakte/dating/500x300/500x300_marks_blue_2011aseichas.swf';
			var rect: Rectangle = getInner();
			_banner = new uif_ecomponent(this, rect.x, rect.y, 500, 300);
			
			var pj: photo_inject = (app as photo_inject);
			var user: Object = pj.userData;
	        var params: String = "?ref_id=" + pj.siteData.ad.ref_id + "&first_name=" + (user.first_name?user.first_name:user.nick) + "&sex=" + (2 - user.sex).toString() + 
	        			"&gender=" + genders[user.sex] + "&bdate=" + user.birthday + "&photo_url=" + (user.pic_big?user.pic_big:user.pic) + (pj.siteData.ad.asMail?"&source=633":'');
			
			var loader: CLoader = new CLoader(_banner, encodeURI(url + params));
			var a_mask: uif_ecomponent = new uif_ecomponent(_banner, 0, 0, _banner.width, _banner.height, 'white');
			loader.mask = a_mask;
			super.createComponents(message, closeFunc, cancelButton);	
		}
		
		override protected function getSize():Point {
			return new Point(520, 500);
		} 
		
		override protected function resizeFromText(): Rectangle {
			_desc.textField.height = _desc.textField.textHeight;
			_desc.height = _desc.textField.height + _desc.getSpace(true) * 2;
			_desc.y = _banner.y + _banner.height + 10;
			height = _desc.y + _desc.height + getSpace(true) * 2 + 35; 
			return getInner();
		}		
	}
}